Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CastKind::Transmute to MIR #108442

Merged
merged 1 commit into from
Mar 23, 2023
Merged

Add CastKind::Transmute to MIR #108442

merged 1 commit into from
Mar 23, 2023

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Feb 25, 2023

Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.

Includes lowering transmute calls to it, so it's used.

Zulip Conversation: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2023

Failed to set assignee to JakobDegen: invalid assignee

Note: Only org members, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 25, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2023

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2023

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@oli-obk
Copy link
Contributor

oli-obk commented Feb 25, 2023

To test it you could make the intrinsic mir pass convert the transmute function calls into an assignment of the new rvalue. That should allow removing all the intrinsic logic for transmute from the various backends

@scottmcm scottmcm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2023

The Miri subtree was changed

cc @rust-lang/miri

@scottmcm scottmcm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 25, 2023
@scottmcm
Copy link
Member Author

scottmcm commented Feb 27, 2023

@oli-obk I see you resolved some comment threads here. Anything else you need from me before this is good to go?

(If it's just that you need time to thoroughly review it that's totally ok!)

@oli-obk
Copy link
Contributor

oli-obk commented Feb 28, 2023

(If it's just that you need time to thoroughly review it that's totally ok!)

yea, just needed to get to a PC to be able to review the diff properly and look at code that isn't nearby your changes.

@bors r+

@bors
Copy link
Contributor

bors commented Feb 28, 2023

📌 Commit 6f49f85 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2023
@bors
Copy link
Contributor

bors commented Mar 23, 2023

⌛ Testing commit 64cce5f with merge e216300...

@bors
Copy link
Contributor

bors commented Mar 23, 2023

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing e216300 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 23, 2023
@bors bors merged commit e216300 into rust-lang:master Mar 23, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 23, 2023
@scottmcm scottmcm deleted the mir-transmute branch March 23, 2023 21:22
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e216300): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.3%, 1.5%] 4
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.6% [-1.6%, -1.6%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.0% [2.9%, 3.1%] 2
Regressions ❌
(secondary)
1.2% [0.9%, 1.5%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.9% [-2.1%, -0.4%] 10
All ❌✅ (primary) 3.0% [2.9%, 3.1%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.8% [0.4%, 1.2%] 4
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
-0.7% [-1.3%, -0.5%] 5
All ❌✅ (primary) -1.4% [-1.4%, -1.4%] 1

@rustbot rustbot added the perf-regression Performance regression. label Mar 23, 2023
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 24, 2023
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
@rylev
Copy link
Member

rylev commented Mar 28, 2023

The regressions are small enough that I don't think this is worth investigating.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Mar 28, 2023
scottmcm added a commit to scottmcm/rust that referenced this pull request Mar 29, 2023
Thanks to the combination of rust-lang#108246 and rust-lang#108442 it could already remove identity transmutes.

With this PR, it can also simplify them to `IntToInt` casts, `Discriminant` reads, or `Field` projections.
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 29, 2023
…jgillot

Simplify transmutes in MIR InstCombine

Thanks to the combination of rust-lang#108246 and rust-lang#108442 it could already remove identity transmutes.

With this PR, it can also simplify them to `IntToInt` casts, `Discriminant` reads, or `Field` projections.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 24, 2023
…i-obk

Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <rust-lang#106281 (comment)> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also rust-lang#108442 (comment), where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Apr 29, 2023
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Jul 18, 2023
Add `intrinsics::transmute_unchecked`

This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`.

Added to enable experimenting with the request in <rust-lang/rust#106281 (comment)> and because the portable-simd folks might be interested for dependently-sized array-vector conversions.

It also simplifies a couple places in `core`.

See also rust-lang/rust#108442 (comment), where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.